package com.hncu.test;

import com.hncu.domain.Student;

import java.util.ArrayList;

public class Demo2 {//存储学生信息
    public static void main(String[] args) {
        //创建集合
        ArrayList<Student> arr = new ArrayList<>();
        //创建对象
        Student stu1 =new Student("阿强",20);
        Student stu2 =new Student("阿珍",21);
        Student stu3 =new Student("阿花",22);
        //添加对象，集合存储的是对象的地址
        arr.add(stu1);
        arr.add(stu2);
        arr.add(stu3);
        //遍历数组
        for (int i = 0; i < arr.size(); i++) {
            String name = arr.get(i).getName();//链式编程
            int age = arr.get(i).getAge();
            System.out.println(name+"..."+age);
        }
    }
}
